﻿@{
    Layout = null;
    System.Data.DataTable dt = ViewBag.dt;
    int rs=0;
    int zrs = dt.Rows.Count;
    for (int i = 0; i < dt.Rows.Count; i++)
    {
        if ((dt.Rows[i]["KWZZ"].ToString()!="" ||dt.Rows[i]["KD"].ToString()!=""))
            rs++;
    }
   
}

<!DOCTYPE html>

<html>
<head>

    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>PYXZSKSZX.JKY</title>
    <link rel="stylesheet" href="../assets/css/cropper.css">
    <link href="../lib/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
    <script src="../lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
    <title>Admin</title>
    <style>
        table {
            width: 98%;
            margin: 5px;
            border-collapse: collapse;
            font-size: 98%;
        }

        table, td, th {
            text-align: center;
            font-size: 98%;
            border: 1px solid black;
        }
    </style>

</head>
<body>

 @*   <table border="1" cellpadding="5" style="border-collapse: collapse;text-align: center;">
	<thead>
		<tr id="HeadTD">
			<td class="sort">姓名</td>
			<td class="sort">学号</td>
			<td class="sort">语文</td>
			<td class="sort">数学</td>
			<td class="sort">英语</td>
			<td class="sort">总分</td>
			<td class="sort">平均分</td>
		</tr>
	</thead>
	<tbody id="ContTD">
		<tr>
			<td>张三</td>
			<td>220305</td>
			<td>11</td>
			<td>22</td>
			<td>33</td>
			<td>22</td>
			<td>44</td>
		</tr>
		<tr>
			<td>李四</td>
			<td>220302</td>
			<td>33</td>
			<td>44</td>
			<td>66</td>
			<td>99</td>
			<td>33</td>
		</tr>
		<tr>
			<td>黄五</td>
			<td>220307</td>
			<td>22</td>
			<td>55</td>
			<td>22</td>
			<td>55</td>
			<td>66</td>
		</tr>
		<tr>
			<td>赵六</td>
			<td>220303</td>
			<td>44</td>
			<td>22</td>
			<td>33</td>
			<td>66</td>
			<td>88</td>
		</tr>
	</tbody>
</table>*@
    <div style="height:200px">
    <H2>考试名称：@ViewBag.ksmc</H2>
        @if (ViewBag.gzdw != "")
        {
            <div style="float:right ;text-align:center;margin:5px">
                <div style="border:3px solid blue">

                    <img src='../jky/GetPTQRCode?url=http://218.29.194.27:5701/jky?dw=@ViewBag.dw' />

                    <p>
                        监考员信息填报
                        <br />【@ViewBag.gzdw】
                    </p>
                </div>
            </div>
        }
        <div style="  text-align:center;flex-direction: row;align-items: center">
            <div style=" height:15px;width:100% ">
                </duv>
                <div style=" margin:20px">
                    @if (ViewBag.gzdw != "")
                    {
                        <h4>【@ViewBag.gzdw】<br />监考员管理</h4>
                    }

                </div>
                @if (ViewBag.gzdw != "")
                {
                    <div class="card-body">

                        <div class="row g-2 align-items-center mb-n3">
                            <div class="col-6 col-sm-4 col-md-2 col-xl mb-3">
                                <a href="../jky/ExportData?dw=@ViewBag.dw&dwmc=@ViewBag.gzdw" class="btn btn-primary btn-pill w-100">
                                    导出数据
                                </a>
                            </div>
                            <div class="col-6 col-sm-4 col-md-2 col-xl mb-3">
                                <a href="../jky/ExportPic?dw=@ViewBag.dw&dwmc=@ViewBag.gzdw" class="btn btn-secondary btn-pill w-100">
                                    导出照片
                                </a>
                            </div>
                            <div class="col-12 col-sm-4 col-md-3 col-xl mb-3">
                                <a href="#" onclick="cancelGZ()" class="btn btn-secondary btn-pill w-100">
                                    取消所有安排
                                </a>
                            </div>
                        </div>
                    </div>
                }

            </div>
        </div>
    </div>
    <div>
        <div>
            <span>输入姓名查询：</span><input id="names" name="names" type="text" value="" placeholder="输入姓名，用逗号分开" /><button onclick="namescx()">查询</button>
            <span>共登记@(zrs)人, </span><span id="showrs">已安排@(rs)人</span>
        </div>
        <table id="downPdf">
            <thead >
                <tr id="HeadTD">
                    <th  class="sort">序号</th>
                    <th class="sort">姓名</th>
                    @if (ViewBag.gzdw != "")
                    {
                        <th class="sort">身份证号</th>
                    }
                    <th class="sort">手机号</th>
                    @if (ViewBag.gzdw != "")
                    {
                        @if (ViewBag.dw == "410811000")
                        {
                            <th class="sort">工作单位</th>
                        }
                        else
                        {
                            <th>银行卡</th>
                        }
                        <th>照片</th>
                    }
                    <th class="sort">考务职责</th>
                    <th class="sort">考点</th>
                    @if (ViewBag.gzdw != "")
                    {
                        <th>操作</th>
                    }
                </tr>
            </thead>
            <tbody id="ContTD">

                @for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string sfz = dt.Rows[i]["sfz"].ToString().Substring(0, 6) + "*********" + dt.Rows[i]["sfz"].ToString().Substring(15, 3);
                    <tr>
                        <td>@(i+1)</td>
                        <td>@dt.Rows[i]["xm"].ToString()</td>

                        @if (ViewBag.gzdw != "")
                        {

                            @* <td>@dt.Rows[i]["sfz"].ToString().Insert(14," ").Insert(6," ")</td>*@
                            <td>@sfz.ToString().Insert(14," ").Insert(6," ")</td>
                        }
                        <td>@dt.Rows[i]["sjh"].ToString().Insert(7," ").Insert(3," ")</td>
                        @if (ViewBag.gzdw != "")
                        {@if (ViewBag.dw == "410811000")
                            {
                               <td> @dt.Rows[i]["gzdw"].ToString()</td>
                            }
                            else
                        {
                            @if (dt.Rows[i]["yhkh"].ToString().Length > 4)
                            {
                                <td>@dt.Rows[i]["yhkh"].ToString().Substring(dt.Rows[i]["yhkh"].ToString().Length-4)</td>
                            }
                            else
                            {
                                <td></td>

                            }
                        }
                            <td> <img width="30px" height="40px" src='../jky/GetPic?xmsfz=@dt.Rows[i]["xm"].ToString().Trim()@dt.Rows[i]["sfz"].ToString().Trim()' /> </td>
                        }
                        <td>
                            @if (dt.Rows[i]["kwzz"].ToString().Length == 0)
                            {
                                <select id="KWZZ_@dt.Rows[i]["sfz"].ToString()" class="form-select">
                                    @if (ViewBag.kwzzs == null)
                                    {
                                        <option value="0">未安排</option>
                                        <option value="1">考区主任</option>
                                        <option value="2">考区副主任</option>
                                        <option value="3">巡考员</option>
                                        <option value="4">主考</option>
                                        <option value="5">副主考</option>
                                        <option value="6">考务组长</option>
                                        <option value="7">考务组</option>
                                        <option value="8">后勤组</option>
                                        <option value="9">宣传组</option>
                                        <option value="A">保密员</option>
                                        <option value="B">送卷员</option>
                                        <option value="C">工作证</option>
                                        <option value="D">播音员</option>
                                        <option value="E">系统管理员</option>
                                        <option value="F">监考甲</option>
                                        <option value="G">监考乙</option>
                                        <option value="H">监考丙</option>
                                        <option value="I">视频监考</option>
                                        <option value="J">信息员</option>
                                        <option value="K">安全组</option>
                                        <option value="L">指挥中心</option>
                                        <option value="M">纪检监督</option>
                                        <option value="N">值班</option>
                                        <option value="O">场外联络员</option>
                                        <option value="P">保密巡逻</option>
                                        <option value="Z">带队证</option>
                                    }
                                    else
                                    {
                                        <option value="0">未安排</option>

                                        for (int j = 1; j < ViewBag.kwzzs.Rows.Count + 1; j++)
                                        {
                                            string kwzz = ViewBag.kwzzs.Rows[j - 1]["kwzz"].ToString().Trim();
                                            <option value="@j">@kwzz</option>
                                        }

                                    }
                                </select>
                            }
                            else
                            {
                                @dt.Rows[i]["kwzz"].ToString()
                            }
                        </td>
                        <td>
                            <div class="btn-group">
                                @if (dt.Rows[i]["kd"].ToString().Length == 0)
                                {
                                    <select id="KD_@dt.Rows[i]["sfz"].ToString()" class="form-select">

                                        <option value="0">未安排</option>
                                        <option value="1">濮阳县一中</option>
                                        <option value="2">濮阳县三中</option>
                                        <option value="3">建业国际学校</option>
                                        <option value="4">学院附中</option>
                                        <option value="5">濮阳县职高</option>
                                        <option value="6">兴濮中学</option>                                        
                                        <option value="7">濮阳县二中</option>
                                        <option value="8">濮阳县三中南校区</option>
                                        


                                    </select>
                                }
                                else
                                {
                                    @dt.Rows[i]["kd"].ToString()
                                }
                            </div>
                        </td>
                        @if (ViewBag.gzdw != "")
                        {
                            <td>
                                <a onclick="QXFG('@dt.Rows[i]["sfz"].ToString()')" href="#">取消分工</a>
                                @if (ViewBag.dw != "410811000")
                                {
                                    <a onclick="del('@dt.Rows[i]["xm"].ToString().Trim()@dt.Rows[i]["sfz"].ToString()')" href="#">删除</a>
                                }
                            </td>
                        }
                    </tr>
                }
            </tbody>
        </table>
    </div>
</body>
<script src="../assets/js/jquery-2.1.1.js"></script>
<script src="../assets/js/cropper.min.js"></script>
<script>
   window.onload = function () {
		var HeadTD = document.getElementById("HeadTD");
		var ContTD = document.getElementById("ContTD");
		var HeadList = HeadTD.getElementsByTagName("th");
		var ContTrList = ContTD.getElementsByTagName("tr");
		var sortArray = new Array();
		var newNode;
		for (var i = 0; i < HeadList.length; i++) {
			HeadList[i].index = i;
			HeadList[i].onclick = function () {
               
				if (this.className) {
					newNode = "";
                    
					for (var j = 0; j < ContTrList.length; j++) {
						sortArray[j] = new Array();
						sortArray[j][0] = ContTrList[j].getElementsByTagName("td")[this.index].innerText;
						sortArray[j][1] = j;
					}
                     
					if (!isNaN(sortArray[0][0])) {
						sortArray.sort(sortNumber);
					} else {
						sortArray.sort();
					}
            
					for (var x = 0; x < ContTrList.length; x++) {
						newNode += "<tr>" + ContTrList[sortArray[x][1]].innerHTML + "</tr>";
					}
                   
					ContTD.innerHTML = newNode;
				}
			}
		}
	}
	function sortNumber(a, b) {
        //alert(a+"---"+b);
        a0 = a[0];
        b0 = b[0];
        //alert(a0+"---"+b0);
        return a0 - b0;
		if (a0 > b0) {
			return 1
		} else if (a0 < b0) {
			return -1
		} else {
			return 0
		}
	}

    function namescx() {

        document.getElementById("downPdf").hidden = false;

        var t = document.getElementById("downPdf");

        var tbody = t.children[1];

        var trs = tbody.children;


        var names = document.getElementById("names").value;


        for (i = 0; i < trs.length; i++) {
            if (names == "") { trs[i].hidden = false }
            else {
                var show = trs[i].children[1].innerHTML.trim();
                //alert(show);
                if (names.indexOf(show) == -1) {
                   
                    if (show.indexOf(names) == -1)
                    {  
                        trs[i].hidden = true;
                    }
                    else
                    {
                        trs[i].hidden = false;
                    }
//trs[i].hidden = true;
                }
                    
                    else
                    trs[i].hidden = false;
            }
        }

    }
    555


    var msg = "@ViewBag.msg";
    if (msg != "") {
         
        alert("取消完成!");
        setTimeout("gotourl()", 1000);
  
           
       


    }
    function gotourl() { window.location = "../jky/admin?dw=@ViewBag.dw"; }


    function cancelGZ() {

        var x;
    @{
        var xx = System.Web.HttpUtility.UrlEncode(ViewBag.gzdw);
    }

               // var url="../jky/cancelFG?dw="+@ViewBag.dw+"&dwmc="+@ViewBag.gzdw+"&token=3255701";
                var url = "../jky/cancelFG?dw=@ViewBag.dw &token=3255701&gzdw=@xx";
        var person = prompt("取消操作将取消所有本单位工作指派,请输入确认码", "");
        if (person != null && person == "3255701") {
            //../jky/cancel?dw=@ViewBag.dw&dwmc=@ViewBag.gzdw
            window.location = url;
        }
        else { alert("操作被取消"); }


    }



    $('#daochu').click(function() {
        alert(1);
        html2canvas(document.getElementById('downPdf'), { //此处的id为要打印的部分
            onrendered: function(canvas) {
                var contentWidth = canvas.width;
                var contentHeight = canvas.height;

                //一页pdf显示html页面生成的canvas高度;
                var pageHeight = contentWidth / 592.28 * 841.89;
                //未生成pdf的html页面高度
                var leftHeight = contentHeight;
                //pdf页面偏移
                var position = 0;
                //a4纸的尺寸[595.28,841.89]，html页面生成的canvas在pdf中图片的宽高
                var imgWidth = 595.28;
                var imgHeight = 592.28 / contentWidth * contentHeight;

                var pageData = canvas.toDataURL('image/jpeg', 1.0);

                var pdf = new jsPDF('', 'pt', 'a4');

                //有两个高度需要区分，一个是html页面的实际高度，和生成pdf的页面高度(841.89)
                //当内容未超过pdf一页显示的范围，无需分页
                if (leftHeight < pageHeight) {
                    pdf.addImage(pageData, 'JPEG', 0, 0, imgWidth, imgHeight);
                } else {
                    while (leftHeight > 0) {
                        pdf.addImage(pageData, 'JPEG', 0, position, imgWidth, imgHeight);
                        leftHeight -= pageHeight;
                        position -= 841.89;
                        //避免添加空白页
                        if (leftHeight > 0) {
                            pdf.addPage();
                        }
                    }
                }

                pdf.save('导出为PDF.pdf'); //
            }
        });
        alert(2);
    });
    function del(xmsfz) {

        var formData = new FormData($("#registerForm")[0]);
        formData.append("xmsfz", xmsfz);
        $.ajax({
            url: "../jky/qxjky",
            type: 'POST',
            data: formData,
            timeout: 10000,
            async: true,
            cache: false,
            contentType: false,
            processData: false,
            success: function(result) {
                alert(result)
               document.getElementById("showrs").innerText = "刷新可重新计算人数" ;
            },
            error: function(returndata) {
                Alert.closedLoading()
            }
        })

    }


    function QXFG(sfz) {

        var formData = new FormData($("#registerForm")[0]);
        formData.append("sfz", sfz);
        $.ajax({
            url: "../jky/qxjkyfg",
            type: 'POST',
            data: formData,
            timeout: 10000,
            async: true,
            cache: false,
            contentType: false,
            processData: false,
            success: function(result) {
                alert(result)
               
                document.getElementById("showrs").innerText = "刷新可重新计算人数" ;
            },
            error: function(returndata) {
                Alert.closedLoading()
            }
        })

    }

    $(".form-select").change(function() {
        //1、拿到结点
        var myselect = document.getElementById(this.id);
        //alert(myselect.innerHTML);
        //2. 拿到选中项的索引：
        var index = myselect.selectedIndex;
        // selectedIndex代表的是你所选中项的index
        //3. 拿到选中项options的value：
        var myselectval = myselect.options[index].value;
        //4:拿到选中项options的text：
        var myselecttext = myselect.options[index].text;

        //   alert(myselecttext);
        //ajax 保存所选的值


        var sfz = this.id.split("_")[1];
        var ZD = this.id.split("_")[0];

        var formData = new FormData($("#registerForm")[0]);
        formData.append("sfz", sfz);
        formData.append("ZD", ZD);
        formData.append("val", myselecttext);
       

        $.ajax({
            url: "../jky/savejkyFG",
            type: 'POST',
            data: formData,
            timeout: 10000,
            async: true,
            cache: false,
            contentType: false,
            processData: false,
            success: function(result) {
                 document.getElementById("showrs").innerText = "刷新可重新计算人数" ;
                if (result != "已记录") alert(result)
            },
            error: function(returndata) {
                Alert.closedLoading()
            }
        })


    })

</script>
</html>
